#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
快速测试：直接访问东财（不使用代理）
"""

import requests
import urllib3

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

TEST_URL = "http://82.push2.eastmoney.com/api/qt/clist/get"
params = {"pn": 1, "pz": 10}

headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
    'Accept': '*/*',
    'Referer': 'http://quote.eastmoney.com/',
}

print("测试直接访问东财（不使用代理）...")
print(f"目标URL: {TEST_URL}\n")

try:
    r = requests.get(TEST_URL, headers=headers, params=params, timeout=10, verify=False)
    print(f"状态码: {r.status_code}")
    
    if r.status_code == 200:
        try:
            data = r.json()
            if 'data' in data:
                print(f"✓ 直接访问成功！")
                print(f"响应数据示例: {str(data)[:200]}...")
            else:
                print(f"响应格式异常")
        except:
            print(f"响应内容: {r.text[:200]}")
    else:
        print(f"✗ 访问失败，状态码: {r.status_code}")
        print(f"响应内容: {r.text[:200]}")
        
except requests.exceptions.Timeout:
    print("✗ 连接超时")
except requests.exceptions.ConnectionError as e:
    print(f"✗ 连接错误: {e}")
except Exception as e:
    print(f"✗ 错误: {e}")

